import 'package:flutter/material.dart';

import 'section.dart';
import 'table_man.dart';

SliverList sliverTableView({
  required List<SectionModel> data,
  Widget? header,
  Widget? footer,
  SemanticIndexCallback? semanticIndexCallback,
}) {
  TableMan man = TableMan();
  man.getCount(data, hasHeader: header != null, hasFooter: footer != null);
  Widget getItem(BuildContext context, int index) {
    man.initItems(context, data, header, footer);
    return man.items[index];
  }

  return SliverList(
    delegate: SliverChildBuilderDelegate(
      (context, index) {
        return getItem(context, index);
      },
      childCount: man.count,
      semanticIndexCallback: semanticIndexCallback ?? (widget, localIndex) {},
    ),
  );
}
